<pre>
&lt;?php

class Model_{$model_name} extends Model_Dec &lcub;

	const TABLE = "{$table_name}";
{foreach $fields as $field}
	
	/**
	 * @var protected ${$field.name} {$field.name} value
	 * @method {$field.type} get_{$field.name}() get_{$field.name}(void)
	 * @method void set_{$field.name}() set_{$field.name}({Model_Autoclass::translate_type($field.type)} ${$field.name})
	 */
	protected ${$field.name}{if ""!=$field.default}="{$field.default}"{/if};
{/foreach}

	/**
	 * @return Model_{$model_name}
	 */
	public function __construct($id=0) &lcub;
		if(0&lt;intval($id)) &lcub;
			$db = DB::select("*")-&gt;from(self::TABLE)-&gt;where("id", "=", $id)-&gt;limit(1);
			$db = $db-&gt;as_assoc()-&gt;execute();
			if($db-&gt;count()&gt;0) &lcub;
				$this-&gt;load($db-&gt;current());
			&rcub;
		&rcub;
	&rcub;

	protected static function get_database_fields() &lcub;
		return array(
{foreach $fields as $field name=fields}
{if !$smarty.foreach.fields.first}
			'{$field.name}' =&gt; __("{$model_name}_{ucfirst($field.name)}"),
{/if}
{/foreach}
		);
	&rcub;

	public function validate() &lcub;
		$validateArray = array();
		foreach (self::get_database_fields() as $key =&gt; $value) &lcub;
			$validateArray[$key] = $this-&gt;get($key);
		&rcub;
		$validation = Validation::factory($validateArray)
{foreach $fields as $field name=fields}
{if !$smarty.foreach.fields.first}
{if !$field.null}
				-&gt;rule('{$field.name}', 'not_empty')
{/if}
{/if}
{if $smarty.foreach.fields.last}
				;
{/if}
{/foreach}
		if ($validation-&gt;check()) &lcub;
			return $validateArray;
		&rcub; else &lcub;
			throw new Validation_Exception('validation', $validation);
		&rcub;
	&rcub;

	public static function get_report() &lcub;
		return DB::select(
{foreach $fields as $field name=fields}
{if $smarty.foreach.fields.first}{$first = $field.name}
				"{$field.name}"
{else}
				, "{$field.name}"
{/if}
{/foreach}
				, array("{$first}", "actions"))
		-&gt;from(self::TABLE)
		-&gt;order_by("{$first}", "ASC");
	&rcub;

&rcub;

</pre>